package com.jihui.security.web.userdetails;

import com.jihui.user.model.JihuiUser;
import com.jihui.user.model.UserManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

/**
 * user details service implementation
 *
 * @author linux_china
 */
public class UserDetailsServiceImpl implements UserDetailsService {
    @Autowired
    private ApplicationContext applicationContext;
    @Autowired
    private UserManager userManager;
//    @Autowired
//    private UserClient userClient;

    public CurrentUserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        JihuiUser account = userManager.findById(Long.parseLong(username));
        //JihuiUser account = new JihuiUser();
        return new CurrentUserDetails(account);
    }

}


